package com.taxt.ui.adapter;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.taxt.R;
import com.taxt.app.AppAdapter;
import com.taxt.http.api.HomeDataApi;
import com.taxt.http.api.JobDataApi;
import com.taxt.widget.MyTextView;

import java.util.List;

/**
 * author : wq
 * <p>
 * time   : 2018/11/05
 * desc   : 受雇信息
 */
public final class JobDataAdapter extends AppAdapter<JobDataApi.Bean> {
    private final List<JobDataApi.Bean> mSelectBusiness;

    public JobDataAdapter(Context context, List<JobDataApi.Bean> mSelectBusines) {
        super(context);
        this.mSelectBusiness = mSelectBusines;
    }


    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ViewHolder();
    }

    private final class ViewHolder extends AppAdapter<?>.ViewHolder {
        private TextView mJobTitle, mJobWork;
        private MyTextView mJobNum;
        private TextView mJobDate, mJobOutWork;

        private ViewHolder() {
            super(R.layout.job_data_item);
            mJobTitle = findViewById(R.id.job_title);
            mJobNum = findViewById(R.id.job_num);
            mJobWork = findViewById(R.id.job_work);
            mJobDate = findViewById(R.id.job_date);
            mJobOutWork = findViewById(R.id.job_work_out);
        }

        @Override
        public void onBindView(int position) {
            JobDataApi.Bean bean = getItem(position);
            mJobTitle.setText(bean.getName());

            mJobNum.setText("统一社会信用代码:   "+bean.getUnifiedSocialCreditCode()+ "HJK90");
            mJobWork.setText(bean.getDuty());
            mJobDate.setText(bean.getEmploymentStartDate());
            mJobOutWork.setText(bean.getEmploymentEndDate());
        }
    }

    public static String ToDBC(String input) {
        char c[] = input.toCharArray();
        for (int i = 0; i < c.length; i++) {
            if (c[i] == ' ') {
                c[i] = '\u3000';
            } else if (c[i] < '\177') {
                c[i] = (char) (c[i] + 65248);
            }
        }
        return new String(c);
    }
}